package com.jcl.cloud.services.login.factory;


import com.jcl.cloud.services.login.constant.LoginTaskRouteEnum;
import com.jcl.cloud.services.login.task.LoginTaskHandler;
import com.jcl.cloud.services.login.task.QcwyLoginTaskHandler;
import com.jcl.cloud.services.login.task.ZlzpLoginTaskHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;

@Service
public class LoginTaskHandlerFactory{

    @Autowired
    private QcwyLoginTaskHandler qcwyLoginTaskHandler;

    @Autowired
    private ZlzpLoginTaskHandler zlzpLoginTaskHandler;

    private Map<LoginTaskRouteEnum, LoginTaskHandler> handlerRoute = new HashMap();

    @PostConstruct
    public void init() {
        this.handlerRoute.put(LoginTaskRouteEnum.QCWY, this.qcwyLoginTaskHandler);
        this.handlerRoute.put(LoginTaskRouteEnum.ZLZP, this.zlzpLoginTaskHandler);
    }

    public LoginTaskHandler getHandler(LoginTaskRouteEnum type) {
        return (LoginTaskHandler)this.handlerRoute.get(type);
    }
}
